package com.example.p333;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SpringBootApplication
public class P333Application {

    public static void main(String[] args) {
        SpringApplication.run(P333Application.class, args);
    }

    @Bean
    public ApplicationRunner booksInitializer(BookService bookService) {
        return args -> {
            List<String> a1 = new ArrayList<>();
            a1.add("Harper Lee");
            bookService.create(
                    new Book("9780061120084", "To Kill a Mockingbird", a1));
            List<String> a2 = new ArrayList<>();
            a2.add("George Orwell");
            bookService.create(
                    new Book("9780451524935", "1984", a2));
            List<String> a3 = new ArrayList<>();
            a3.add("J.R.R. Tolkien");
            bookService.create(
                    new Book("9780618260300", "The Hobbit", a3));
        };
    }
}
